// 登录 注册 相关的api接口

import service from '@/utils/request'
import { unimpeded } from '@/utils/request' // unimpeded 请求无 请求拦截和响应拦截
import constant from '@/utils/constant'
import Qs from 'qs'

const root = (process.env.NODE_ENV === 'development' ? '/api' : '')

// 密码登录
export function loginPass(data) {
  return unimpeded({
    url: root + constant.login_pass,
    method: 'post',
    data: Qs.stringify(data),
  })
}
// 验证码登录
export function loginEmail(data) {
  return unimpeded({
    url: root + constant.login_email,
    method: 'post',
    data: Qs.stringify(data),
  })
}
// 是否登录
export function loginLegal() {
  return service({
    url: root + constant.login_legal,
    method: 'get',
  })
}
// 发送邮箱验证码
export function sendEmail(params) {
  return unimpeded({
    url: root + constant.send_email,
    method: 'get',
    params: params
  })
}
// 根据邮箱注册
export function regEmail(data) {
  return unimpeded({
    url: root + constant.reg_email,
    method: 'post',
    data: data
  })
}
// 通过邮箱 修改密码
export function resetPassEmail(data) {
  return unimpeded({
    url: root + constant.reset_pass_email,
    method: 'post',
    data: Qs.stringify(data)
  })
}
// 邮箱查重
export function emailRepet(params) {
  return unimpeded({
    url: root + constant.email_repet,
    method: 'get',
    params: params
  })
}
// 手机号查重
export function phoneRepet(params) {
  return unimpeded({
    url: root + constant.phone_repet,
    method: 'get',
    params: params
  })
}
// 用户名查重
export function usernameRepet(params) {
  return unimpeded({
    url: root + constant.username_repet,
    method: 'get',
    params: params
  })
}

// 登出
export function logout() {
  return service({
    url: root + constant.logout,
    method: 'get',
  })
}
// 登录后查询菜单
export function menuList(params) {
  return service({
    url: root + constant.menu_list,
    method: 'get',
    params: params
  })
}
// 完善企业信息时, 删除图片
export function delImgCorporation(data) {
  return service({
    url: root + constant.del_img_corporation,
    method: 'post',
    params: data
  })
}

// 注册阶段选择所有网点
export function allBranch(params) {
  return service({
    url: root + constant.all_branch,
    method: 'get',
    params: params
  })
}
